function getAllUsers()
{
	$.ajax(
	{

		type : 'GET',
		contentType : 'application/json',
		url : 'restful-services/crowd-sourcing/users',
		dataType : "json",
		success : function(data, textStatus, jqXHR)
		{
			$("#myDiv").html('success');
			var s = "";
			var i = 0;
			for (i = 0; i < data.length; i++)
			{
				s = s + "username: " + data[i].username + " pass: "
						+ data[i].password;
			}
			$("#myDiv2").html(s);
		},
		error : function(jqXHR, textStatus, errorThrown)
		{
			$("#myDiv2").html('error geting all users');
		}

	});
}

function register(form)
{
	if (form.password.value != form.rePassword.value)
	{
		alert("password doesn't match");
		return;
	}
	var user = new Object();
	user.username = form.username.value;
	user.password = form.password.value;
	user.sirName = form.sirName.value;
	user.lastName = form.lastName.value;
	user.address = new Object();
	user.address.city = form.city.value;
	user.address.country = form.country.value;
	user.address.street = form.street.value;
	$.ajax(
	{

		type : 'PUT',
		contentType : 'application/json',
		url : 'restful-services/register-api/register/user',
		dataType : "json",
		data : JSON.stringify(user),
		success : function(data, textStatus, jqXHR)
		{
			window.location.href = '/${project.build.finalName}/crowd';
		},
		error : function(jqXHR, textStatus, errorThrown)
		{
			if (409 == jqXHR.status)
			{
				alert("username already exists.");
			} 
			else
			{
				$("#myDiv3").html(jqXHR.responseText);
			}

		}

	});
}

function register7(username, password)
{
	var r = new REST.Request();
	r.setURI("http://localhost:8080/amiranddror/about.html");
	r.setMethod("GET");
	r.execute(function(status, request, entity)
	{
		$("#myDiv").html(status);
	});
}

function register8(username, password)
{
	$.ajax(
	{
		url : "about.html",
		cache : false
	}).done(function(html)
	{
		$("#myDiv").html(html);
	});
}

function registerUser(username, password)
{

	var user = new Object;
	user.username = username;
	user.password = password;
	document.getElementById("myDiv").innerHTML = user.username;

	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	} else
	{// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	document.getElementById("myDiv").innerHTML = "pass1";
	xmlhttp.open("POST", "restful-services/crowd-sourcing/users/register",
			false);
	xmlhttp.setRequestHeader("Content-type", "application/json");
	document.getElementById("myDiv").innerHTML = "pass2";
	xmlhttp.send(user);
	document.getElementById("myDiv").innerHTML = xmlhttp.status;
}

function show(username, password)
{
	document.getElementById("myDiv").innerHTML = toJson(username, password);
}
